import 'package:word_game/battle/battleable.dart';
import 'package:word_game/engine/core.dart';
import 'battle_event.dart';

class Monster extends Living with Battleable {
  List<Process> processes = [];
  // Monster(String name) : super(name);
  Monster(Map map) : super(map){
    if (map != null) {
      var list = map['processes'];
      if (list != null) {
        for (var item in list) {
          Process obj = Process();
          if (item is String) {

          } else if (item is Map) {
            obj = Process();
            obj.thingCode = item['thingCode'];
          }
          processes.add(obj);
        }
      }
      
    }

    this.add(BattleEvent());
  }

  @override
  void copyData(dynamic obj) {
    super.copyData(obj);
    for (var process in obj.processes) {
      this.processes.add(process);
    }
  }

  @override
  void onVictory() {
    this.vitality = this.maxVitality;
  }

  @override
  void onDefeated() {
    this.preview.removeById(this);
    Focus.current.back();
  }
}